package com.tedu.day04_mybatistest.mapper;

import com.tedu.day04_mybatistest.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IUserMapper {
    @Insert("INSERT INTO user(username,password,nickname,age,created) VALUES(#{username},#{password},#{nickname},#{age},#{created})")
    public int insert(User user);

    @Delete("DELETE FROM user WHERE username=#{username}")
    public int deleteByUserName(String username);

    @Update("UPDATE user set username=#{username},password=#{password},nickname=#{nickname},age=#{age} WHERE id=#{id}")
    public int update(User user);

    @Select("SELECT id,username,password,nickname,age,created FROM user")
    public List<User> selectAll();
    @Select("SELECT id,username,password,nickname,age,created FROM user WHERE username=#{username} AND password=#{password}")
    public User selectOne(@Param("username")String username,@Param("password") String password);
}
